package com.example.demo.service.impl;

import com.example.demo.mapper.EnvParamsMapper;
import com.example.demo.entity.EnvParams;
import com.example.demo.service.EnvParamsService;
import com.example.demo.utils.DateToStamp;
import com.example.demo.utils.PageInfoNew;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class EnvParamsServiceImpl implements EnvParamsService {
    @Resource
    EnvParamsMapper envParamsMapper;

    @Override
    public void insert(EnvParams envParams) {
        envParams.setCreateTime(DateToStamp.getTimeStamp());
        envParams.setUpdateTime(DateToStamp.getTimeStamp());
        envParamsMapper.insert(envParams);
    }

    @Override
    public void update(EnvParams envParams) {
        envParams.setUpdateTime(DateToStamp.getTimeStamp());
        envParamsMapper.update(envParams);
    }

    @Override
    public EnvParams selectOne(int id) {
        return envParamsMapper.selectOne(id);
    }

    @Override
    public PageInfoNew<EnvParams> selectByProjectId(int pageNum, int pageSize, int projectId) {
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfoNew<>(envParamsMapper.selectByProjectId(projectId));
    }
}
